package cate.game.play.skill.passive.exp;

import cate.common.table.d.GDSkill;
import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.effect.SkillEffect;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 攻击时有14%的概率攻击失败
 */
public class 锐不可当PH extends PassiveHandler {

	private int 失败概率;

	//失败概率=1400
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		失败概率 = args.getInt("失败概率", 0);
	}

	@Override
	public void beforeSkillSettleAsActor(SkillActionCtx action, SkillEffect effect, Fighter target) {
		if (!action.getSkill().cfg.isEffectType(GDSkill.EffectType.伤害)) {
			return;
		}
		if (XT.chance(失败概率)) {
			effect.getTargetCtx(target).setForceMiss(true);
		}
	}
}
